package com.lxw.filesystem.controller;


import com.lxw.api.filesystem.FileSystemControllerApi;
import com.lxw.filesystem.service.IFileSystemService;
import com.lxw.filesystem.service.IOssService;
import com.lxw.framework.domain.filesystem.FileSystem;
import com.lxw.framework.domain.filesystem.response.UploadFileResult;
import com.lxw.framework.model.response.CommonCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;
import java.util.UUID;


@RestController
public class FileSystemController implements FileSystemControllerApi {


    @Autowired
    IFileSystemService fileSystemService;
    @PostMapping("/filesystem/upload")
    @Override
    public UploadFileResult upload(
            @RequestParam("file") MultipartFile multipartFile,
            String filetag, String businesskey, String metadata) {

        //文件上传
        FileSystem fileSystem = fileSystemService.upload( multipartFile, filetag, businesskey, metadata);


        UploadFileResult uploadFileResult = new UploadFileResult(CommonCode.SUCCESS,fileSystem);
        return uploadFileResult;
    }
}
